$.fn.tabOn = function(opt){
    if($(this).length==0) return false;
    var opts = $.extend({
        toggleClass : "",
        menu: "a",
        box: "div",
        evt : "click",
        page: 0
    },opt);

    function tab(o){
        this.o = o;
        this.menu = o.find(opts.menu);
        this.box = o.find(opts.box);
        this.evt = opts.evt;
        this.toggleClass = opts.toggleClass;
        this.page = opts.page;
    }

    tab.prototype = {
        init : function(){
            this.box.eq(this.page).show();
            if(opts.toggleClass!=""){
                this.menu.eq(this.page).addClass(this.toggleClass);    
            }
            this.toggleCnt();
        },
        toggleCnt : function(){
            var _this = this;
            this.menu.on(_this.evt,function(){
                var $this = $(this), 
                    i = $this.index(_this.menu);
                if(opts.toggleClass!=""){
                    $this.addClass(_this.toggleClass).siblings().removeClass(_this.toggleClass);
                }
                _this.box.eq(i).show().siblings(opts.box).hide();
            })
        }
    }

    return this.each(function(){
        var $this = $(this);
        var obj = new tab($this);
        obj.init();
    })
}


$.fn.placeholder = function(){
    if($(this).length==0) return false;
    function Placeholder(o){
        this.o = o;
    }
    Placeholder.prototype = {
        init: function(){
            var _this = this;

            if(!_this.checkIe()) return;

            var placeholder = this.o.attr("placeholder");
            if(!placeholder){ return; }
            this.o.val(placeholder);
            this.o.on("focus",function(){
                var $this = $(this);
                if( $this.val() == $this.attr("placeholder")){
                    $this.val("");
                }
            }).on("blur",function(){
                var $this = $(this);
                if( !$this.val()){
                    $this.val(placeholder);
                }
            })

        },
        checkIe: function(){
            var isIE = document.all && !window.atob;  //ie<=9
            if(isIE){
                return true;
            }
            return false;
        }
    }
    return this.each(function(){            
        var $this = $(this);
        var obj = new Placeholder($this);  
        obj.init();
    })
}

